package com.yykj.drup.server.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yykj.drup.server.mapper.StoreProductDao;
import com.yykj.drup.server.model.StoreProduct;
import com.yykj.drup.server.service.StoreProductService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author zeng
 * @Date 2022/3/21
 */
@Service
public class StoreProductServiceImpl extends ServiceImpl<StoreProductDao, StoreProduct> implements StoreProductService {
    @Override
    public StoreProduct findByStoreIdAndProductId(Integer storeId, Integer productId) {
        QueryWrapper<StoreProduct> wrapper = new QueryWrapper<>();
        wrapper.eq("store_id",storeId).eq("product_id",productId);
        return this.getOne(wrapper);
    }

    @Override
    public List<StoreProduct> findStoreProductByProductId(Integer productId) {
        QueryWrapper<StoreProduct> wrapper = new QueryWrapper<>();
        wrapper.eq("product_id",productId);
        return this.list(wrapper);
    }

    @Override
    public List<StoreProduct> findStoreProductByStoreId(Integer storeId) {
        QueryWrapper<StoreProduct> wrapper = new QueryWrapper<>();
        wrapper.eq("store_id",storeId);
        return this.list(wrapper);
    }
}
